home *** CD-ROM | disk | FTP | other *** search
- #define banner "This is TFtoPL, Version 3.1"
- #line 12 "g:\virtfont\tftopl.ch"
-
- #define local_banner "Atari ST Version 1.0, May 21, 1990 by S. Lindner"
- #line 66 "g:\virtfont\tftopl.web"
-
- #define NAME_LENGTH 120
- #define odd(a)((a)&0x1)
- #define tfm_size 30000
- #define lig_size 5000
- #define hash_size 5003 \
- \
-
- #define incr(a)(a)++
- #define decr(a)(a)--
- #define do_nothing \
-
- #define no_tag 0
- #define lig_tag 1
- #define list_tag 2
- #define ext_tag 3 \
-
- #define stop_flag 128
- #define kern_flag 128 \
-
- #define tfm(a)internal_tfm[a+1000] \
-
- #define pabort(a){fprintf(output,"%s\n",a); \
- fprintf(output,"%s\n","Sorry, but I can't go on; are you sure this is a TFM?"); \
- goto final_end; \
- }
- #define pabortp(a,b){fprintf(output,"%s\n",a,b); \
- fprintf(output,"%s\n","Sorry, but I can't go on; are you sure this is a TFM?"); \
- goto final_end; \
- }
- #define pabortpp(a,b,c){fprintf(output,"%s\n",a,b,c); \
- fprintf(output,"%s\n","Sorry, but I can't go on; are you sure this is a TFM?"); \
- goto final_end; \
- } \
-
- #define eval_two_bytes(a){if(tfm(tfm_ptr)>127) \
- pabort("One of the subfile sizes is negative!"); \
- \
- a= tfm(tfm_ptr)*0400+tfm(tfm_ptr+1); \
- tfm_ptr+= 2; \
- } \
-
- #define check_sum 24
- #define design_size check_sum+4
- #define scheme design_size+4
- #define family scheme+40
- #define random_word family+20
- #define char_info(a)4*(char_base+a)
- #define width_index(a)tfm(char_info(a))
- #define nonexistent(a)((a<bc)||(a>ec)||(width_index(a)==0))
- #define height_index(a)(tfm(char_info(a)+1)/16)
- #define depth_index(a)(tfm(char_info(a)+1)%16)
- #define italic_index(a)(tfm(char_info(a)+2)/4)
- #define tag(a)(tfm(char_info(a)+2)%4)
- #define reset_tag(a)tfm(char_info(a)+2)= 4*italic_index(a)+no_tag
- #define remainder(a)tfm(char_info(a)+3)
- #define width(a)4*(width_base+width_index(a))
- #define height(a)4*(height_base+height_index(a))
- #define depth(a)4*(depth_base+depth_index(a))
- #define italic(a)4*(italic_base+italic_index(a))
- #define exten(a)4*(exten_base+remainder(a))
- #define lig_step(a)4*(lig_kern_base+(a))
- #define kern(a)4*(kern_base+a)
- #define param(a)4*(param_base+a) \
-
- #define vanilla 0
- #define mathsy 1
- #define mathex 2 \
-
- #define out(a)fprintf(pl_file,a)
- #define outc(a)putc(a,pl_file)
- #define outl(a)fprintf(pl_file,"%ld",(long)(a)) \
-
- #define bad(a){perfect= false;if(chars_on_line>0)fprintf(output," \n"); \
- chars_on_line= 0;fprintf(output,"Bad TFM file: %s",a); \
- }
- #define badp(a,b){perfect= false;if(chars_on_line>0)fprintf(output," \n"); \
- chars_on_line= 0;fprintf(output,"Bad TFM file: ");fprintf(output,a,b); \
- }
- #define badpp(a,b,c){perfect= false;if(chars_on_line>0)fprintf(output," \n"); \
- chars_on_line= 0;fprintf(output,"Bad TFM file: ");fprintf(output,a,b,c); \
- } \
-
- #define range_error(a){perfect= false; \
- fprintf(output," \n%s index for character ",a); \
- print_octal(c);fprintf(output,"%s\n"," is too large;"); \
- fprintf(output,"%s\n","so I reset it to zero."); \
- }
- #define bad_char(a,b){perfect= false;if(chars_on_line>0)fprintf(output,"%s\n"," "); \
- chars_on_line= 0;fprintf(output,"Bad TFM file: %ld nonexistent character ",(long)(a)); \
- print_octal(b);fprintf(output,".\n"); \
- }
- #define correct_bad_char(a,b){perfect= false; \
- if(chars_on_line>0)fprintf(output,"%s\n"," "); \
- chars_on_line= 0;fprintf(output,"Bad TFM file: %ld nonexistent character ",(long)a); \
- print_octal(tfm(b));fprintf(output,".\n");tfm(b)= bc; \
- } \
-
- #define bad_design(a){bad("Design size "a"!"); \
- \
- fprintf(output,"%s\n","I've set it to 10 points."); \
- out(" D 10"); \
- } \
-
- #define check_fix(a,b)if((tfm(a)>0)&&(tfm(a)<255)) \
- {tfm(a)= 0;tfm((a)+1)= 0;tfm((a)+2)= 0;tfm((a)+3)= 0; \
- badpp("%s %ld is too big;",b,(long)i); \
- fprintf(output,"%s\n","I have set it to zero."); \
- } \
-
- #define nonzero_fix(a)(tfm(a)>0)||(tfm(a+1)>0)||(tfm(a+2)>0)||(tfm(a+3)>0) \
-
- #define unreachable 0
- #define pass_through 1
- #define accessible 2 \
-
- #define simple 0
- #define left_z 1
- #define right_z 2
- #define both_z 3
- #define pending 4 \
-
- /*2:*/
- #line 79 "g:\virtfont\tftopl.web"
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "portab.h"
-
- FILE*output= stdout;
- char tfm_name[NAME_LENGTH],pl_name[NAME_LENGTH],output_name[NAME_LENGTH];
-
- /*5:*/
- #line 115 "g:\virtfont\tftopl.web"
-
- typedef UWORD tfm_size_type;
- typedef UWORD lig_size_type;
- typedef UWORD hash_size_type;
-
- /*:5*//*19:*/
- #line 439 "g:\virtfont\tftopl.web"
-
- typedef UBYTE byte;
- typedef tfm_size_type index;
-
- /*:19*/
- #line 88 "g:\virtfont\tftopl.web"
-
- /*7:*/
- #line 140 "g:\virtfont\tftopl.web"
-
- FILE*tfm_file;
-
- /*:7*//*9:*/
- #line 182 "g:\virtfont\tftopl.web"
-
- UWORD lf,lh,bc,ec,nw,nh,nd,ni,nl,nk,ne,np;
-
-
- /*:9*//*17:*/
- #line 425 "g:\virtfont\tftopl.web"
-
- FILE*pl_file;
-
- /*:17*//*21:*/
- #line 446 "g:\virtfont\tftopl.web"
-
- byte internal_tfm[tfm_size+1002];
-
-
- /*:21*//*24:*/
- #line 538 "g:\virtfont\tftopl.web"
-
- LONG char_base,width_base,height_base,depth_base,italic_base,
- lig_kern_base,kern_base,exten_base,param_base;
-
-
- /*:24*//*27:*/
- #line 594 "g:\virtfont\tftopl.web"
-
- UBYTE font_type;
-
- /*:27*//*29:*/
- #line 613 "g:\virtfont\tftopl.web"
-
- char ASCII_04[33],
- ASCII_10[33],
- ASCII_14[33];
-
- char MBL_string[4],
- RI_string[4],
- RCE_string[4];
-
-
- /*:29*//*31:*/
- #line 632 "g:\virtfont\tftopl.web"
-
- UBYTE dig[12];
-
- /*:31*//*34:*/
- #line 669 "g:\virtfont\tftopl.web"
-
- UWORD level;
-
- /*:34*//*47:*/
- #line 854 "g:\virtfont\tftopl.web"
-
- UBYTE chars_on_line;
- boolean perfect;
-
- /*:47*//*49:*/
- #line 890 "g:\virtfont\tftopl.web"
-
- UWORD i;
- UWORD c;
- UBYTE d;
- index k;
- UWORD r;
- UBYTE count;
-
- /*:49*//*65:*/
- #line 1112 "g:\virtfont\tftopl.web"
-
- struct{
- UWORD cc;
- lig_size_type rr;
- }label_table[259];
- UWORD label_ptr;
- UWORD sort_ptr;
- UWORD boundary_char;
- UWORD bchar_label;
-
- /*:65*//*67:*/
- #line 1133 "g:\virtfont\tftopl.web"
-
- UBYTE activity[lig_size+1];
- lig_size_type ai,acti;
-
- /*:67*//*91:*/
- #line 1488 "g:\virtfont\tftopl.web"
-
- LONG hash[hash_size+1];
- UBYTE class[hash_size+1];
- UWORD lig_z[hash_size+1];
- hash_size_type hash_ptr;
- hash_size_type hash_list[hash_size+1];
- hash_size_type h,hh;
- UWORD x_lig_cycle,y_lig_cycle;
-
- /*:91*/
- #line 89 "g:\virtfont\tftopl.web"
-
- void initialize(void)
- {if(output_name[0]!='\0'){
- output= fopen(output_name,"w");
- if(output==NULL){
- fprintf(stderr,"I can't open log file \"%s\"\n",output_name);
- fprintf(stderr,"The output will appear on the terminal\n");
- output= stdout;
- }
- }
- fprintf(output,"%s\n",banner);
- fprintf(output,"%s\n",local_banner);
- /*8:*/
- #line 149 "g:\virtfont\tftopl.web"
-
- tfm_file= fopen(tfm_name,"rb");
- if(tfm_file==NULL){
- fprintf(stderr,"I can't open TFM file \"%s\"\n",tfm_name);
- exit(1);
- }
-
- /*:8*//*18:*/
- #line 428 "g:\virtfont\tftopl.web"
-
- pl_file= fopen(pl_name,"w");
- if(pl_file==NULL){
- fprintf(stderr,"I can't open the PL file \"%s\"\n",pl_name);
- exit(1);
- }
-
- /*:18*//*30:*/
- #line 623 "g:\virtfont\tftopl.web"
-
- strcpy(ASCII_04+1," !\"#$%&'()*+,-./0123456789:;<=>?");
- strcpy(ASCII_10+1,"âħABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_");
- strcpy(ASCII_14+1,"`abcdefghijklmnopqrstuvwxyz{|}~ ");
- strcpy(MBL_string+1,"MBL");strcpy(RI_string+1,"RI ");
- strcpy(RCE_string+1,"RCE");
-
- /*:30*//*35:*/
- #line 672 "g:\virtfont\tftopl.web"
-
- level= 0;
-
- /*:35*//*48:*/
- #line 858 "g:\virtfont\tftopl.web"
-
- chars_on_line= 0;
- perfect= true;
-
- /*:48*//*66:*/
- #line 1122 "g:\virtfont\tftopl.web"
-
- boundary_char= 256;bchar_label= (UWORD)(077777L);
- label_ptr= 0;label_table[0].rr= 0;
-
- /*:66*/
- #line 101 "g:\virtfont\tftopl.web"
-
- }
-
- /*:2*//*32:*/
- #line 638 "g:\virtfont\tftopl.web"
- void out_digs(LONG j)
- {do{decr(j);outc('0'+dig[j]);
- }
- while(j!=0);
- }
-
- void print_digs(LONG j)
- {do{decr(j);putc('0'+dig[j],output);
- }
- while(j!=0);
- }
-
- /*:32*//*33:*/
- #line 654 "g:\virtfont\tftopl.web"
- void print_octal(byte c)
- {
- UBYTE j;
-
- putc('\'',output);
- for(j= 0;j<=2;j++)
- {dig[j]= c%8;c= c/8;
- }
- print_digs(3);
- }
-
- /*:33*//*36:*/
- #line 678 "g:\virtfont\tftopl.web"
- void out_ln(void)
- {
- UBYTE l;
-
- putc('\n',pl_file);
- for(l= 1;l<=level;l++)out(" ");
- }
-
- void left(void)
- {incr(level);outc('(');
- }
-
- void right(void)
- {decr(level);outc(')');out_ln();
- }
-
- /*:36*//*37:*/
- #line 698 "g:\virtfont\tftopl.web"
- void out_BCPL(index k)
- {
- UBYTE l;
-
- outc(' ');l= tfm(k);
- while(l>0){
- incr(k);decr(l);
- switch(tfm(k)/040){
- case 1:outc(ASCII_04[1+(tfm(k)%040)]);break;
- case 2:outc(ASCII_10[1+(tfm(k)%040)]);break;
- case 3:outc(ASCII_14[1+(tfm(k)%040)]);break;
- }
- }
- }
-
- /*:37*//*38:*/
- #line 719 "g:\virtfont\tftopl.web"
- void out_octal(index k,index l)
- {
- UWORD a;
- UBYTE b;
- UBYTE j;
-
- out(" O ");
- a= 0;b= 0;j= 0;
- while(l>0)/*39:*/
- #line 734 "g:\virtfont\tftopl.web"
-
- {decr(l);
- if(tfm(k+l)!=0)
- {while(b>2)
- {dig[j]= a%8;a= a/8;b= b-3;incr(j);
- }
- switch(b){
- case 0:a= tfm(k+l);break;
- case 1:a= a+2*tfm(k+l);break;
- case 2:a= a+4*tfm(k+l);break;
- }
- }
- b= b+8;
- }
-
- /*:39*/
- #line 727 "g:\virtfont\tftopl.web"
- ;
- while((a>0)||(j==0))
- {dig[j]= a%8;a= a/8;incr(j);
- }
- out_digs(j);
- }
-
- /*:38*//*40:*/
- #line 754 "g:\virtfont\tftopl.web"
- void out_char(byte c)
- {if(font_type>vanilla)
- {tfm(0)= c;out_octal(0,1);
- }
- else if((c>='0')&&(c<='9')){
- out(" C ");outc(c);}
- else if((c>='A')&&(c<='Z')){
- out(" C ");outc(ASCII_10[c-'A'+2]);}
- else if((c>='a')&&(c<='z')){
- out(" C ");outc(ASCII_14[c-'a'+2]);}
- else{tfm(0)= c;out_octal(0,1);
- }
- }
-
- /*:40*//*41:*/
- #line 771 "g:\virtfont\tftopl.web"
- void out_face(index k)
- {
- UBYTE s;
- UBYTE b;
-
- if(tfm(k)>=18)out_octal(k,1);
- else{out(" F ");
- s= tfm(k)%2;b= tfm(k)/2;
- outc(MBL_string[1+(b%3)]);
- outc(RI_string[1+s]);
- outc(RCE_string[1+(b/3)]);
- }
- }
-
- /*:41*//*42:*/
- #line 792 "g:\virtfont\tftopl.web"
- void out_fix(index k)
- {
- UWORD a;
- LONG f;
- UBYTE j;
- LONG delta;
-
- out(" R ");
- a= (tfm(k)*16)+(tfm(k+1)/16);
- f= ((long)(tfm(k+1)%16)*0400+tfm(k+2))*0400+tfm(k+3);
- if(a>03777)/*45:*/
- #line 828 "g:\virtfont\tftopl.web"
-
- {outc('-');a= 010000-a;
- if(f>0)
- {f= 04000000L-f;decr(a);
- }
- }
-
- /*:45*/
- #line 802 "g:\virtfont\tftopl.web"
- ;
- /*43:*/
- #line 809 "g:\virtfont\tftopl.web"
-
- {j= 0;
- do{dig[j]= a%10;a= a/10;incr(j);
- }
- while(a!=0);
- out_digs(j);
- }
-
- /*:43*/
- #line 803 "g:\virtfont\tftopl.web"
- ;
- /*44:*/
- #line 820 "g:\virtfont\tftopl.web"
-
- {outc('.');f= 10*f+5;delta= 10;
- do{if(delta>04000000L)f= f+02000000L-(delta/2);
- outl(f/04000000L);f= 10*(f%04000000L);delta= delta*10;
- }
- while(f>delta);
- }
-
- /*:44*/
- #line 804 "g:\virtfont\tftopl.web"
- ;
- }
-
- /*:42*//*54:*/
- #line 943 "g:\virtfont\tftopl.web"
- void check_BCPL(index k,index l)
- {
- index j;
- byte c;
-
- if(tfm(k)>=l)
- {bad("String is too long; I've shortened it drastically.");
-
- tfm(k)= 1;
- }
- for(j= k+1;j<=k+tfm(k);j++)
- {c= tfm(j);
- if((c=='(')||(c==')'))
- {bad("Parenthesis in string has been changed to slash.");
-
- tfm(j)= '/';
- }
- else if((c<' ')||(c>'~'))
- {bad("Nonstandard ASCII code has been blotted out.");
-
- tfm(j)= '?';
- }
- else if((c>='a')&&(c<='z'))tfm(j)= c+'A'-'a';
- }
- }
-
- /*:54*//*94:*/
- #line 1538 "g:\virtfont\tftopl.web"
- void hash_input(void)
- {
- UBYTE cc;
- UBYTE zz;
- UBYTE y;
- LONG key;
- LONG t;
-
- if(hash_ptr==hash_size)return;
- /*95:*/
- #line 1564 "g:\virtfont\tftopl.web"
-
- k= (index)(lig_step(i));y= tfm(k+1);t= tfm(k+2);cc= simple;zz= tfm(k+3);
- if(t>=kern_flag)zz= y;
- #line 18 "g:\virtfont\tftopl.ch"
- else{switch((int)t){
- #line 1568 "g:\virtfont\tftopl.web"
- case 0:
- case 6:do_nothing;break;
- case 5:
- case 11:zz= y;break;
- case 1:
- case 7:cc= left_z;break;
- case 2:cc= right_z;break;
- case 3:cc= both_z;break;
- }
- }
-
- /*:95*/
- #line 1547 "g:\virtfont\tftopl.web"
- ;
- key= 256*c+y+1;h= (index)((1009*key)%hash_size);
- while(hash[h]>0)
- {if(hash[h]<=key)
- {if(hash[h]==key)return;
- t= hash[h];hash[h]= key;key= t;
- t= class[h];class[h]= cc;cc= t;
- t= lig_z[h];lig_z[h]= zz;zz= t;
- }
- if(h>0)decr(h);else h= hash_size;
- }
- hash[h]= key;class[h]= cc;lig_z[h]= zz;incr(hash_ptr);hash_list[hash_ptr]= h;
- }
-
- /*:94*//*96:*/
- #line 1582 "g:\virtfont\tftopl.web"
- index f(index h,index x,index y);
-
- index eval(index x,index y)
- {
- LONG key;
-
- key= 256*x+y+1;h= (index)((1009*key)%hash_size);
- while(hash[h]>key)
- if(h>0)decr(h);else h= hash_size;
- if(hash[h]<key)return(y);
- else return(f(h,x,y));
- }
-
- /*:96*//*97:*/
- #line 1598 "g:\virtfont\tftopl.web"
- index f(index h,index x,index y)
- {
- switch(class[h]){
- case simple:do_nothing;break;
- case left_z:class[h]= pending;lig_z[h]= eval(lig_z[h],y);class[h]= simple;
- break;
- case right_z:class[h]= pending;lig_z[h]= eval(x,lig_z[h]);class[h]= simple;
- break;
- case both_z:class[h]= pending;lig_z[h]= eval(eval(x,lig_z[h]),y);
- class[h]= simple;break;
- case pending:x_lig_cycle= x;y_lig_cycle= y;lig_z[h]= 257;class[h]= simple;
- break;
- }
- return(lig_z[h]);
- }
-
- /*:97*//*98:*/
- #line 1624 "g:\virtfont\tftopl.web"
- boolean organize(void)
- {
- index tfm_ptr;
-
- /*22:*/
- #line 466 "g:\virtfont\tftopl.web"
-
- fread(&tfm(0),sizeof(tfm(0)),1,tfm_file);
- if(tfm(0)>127)pabort("The first byte of the input file exceeds 127!");
-
- if(feof(tfm_file))pabort("The input file is only one byte long!");
-
- fread(&tfm(1),sizeof(tfm(1)),1,tfm_file);lf= tfm(0)*0400+tfm(1);
- if(lf==0)
- pabort("The file claims to have length zero, but that's impossible!");
-
- if(4*lf-1>tfm_size)pabort("The file is bigger than I can handle!");
-
- for(tfm_ptr= 2;tfm_ptr<4*lf;tfm_ptr++)
- {if(feof(tfm_file))
- pabort("The file has fewer bytes than it claims!");
-
- fread(&tfm(tfm_ptr),sizeof(tfm(tfm_ptr)),1,tfm_file);
- }
- getc(tfm_file);
- if(!feof(tfm_file))
- {fprintf(output,"%s\n","There's some extra junk at the end of the TFM file,");
-
- fprintf(output,"%s\n","but I'll proceed as if it weren't there.");
- }
-
- /*:22*/
- #line 1628 "g:\virtfont\tftopl.web"
- ;
- /*23:*/
- #line 501 "g:\virtfont\tftopl.web"
-
- {tfm_ptr= 2;
- eval_two_bytes(lh);
- eval_two_bytes(bc);
- eval_two_bytes(ec);
- eval_two_bytes(nw);
- eval_two_bytes(nh);
- eval_two_bytes(nd);
- eval_two_bytes(ni);
- eval_two_bytes(nl);
- eval_two_bytes(nk);
- eval_two_bytes(ne);
- eval_two_bytes(np);
- if(lh<2)pabortp("The header length is only %ld!",(long)lh);
-
- if(nl>4*lig_size)
- pabort("The lig/kern program is longer than I can handle!");
-
- if((bc>ec+1)||(ec>255))pabortpp("The character code range %ld..%ld is illegal!",(long)bc,(long)ec);
-
- if((nw==0)||(nh==0)||(nd==0)||(ni==0))
- pabort("Incomplete subfiles for character dimensions!");
-
- if(ne>256)pabortp("There are %ld extensible recipes!",(long)ne);
-
- if(lf!=6+lh+(ec-bc+1)+nw+nh+nd+ni+nl+nk+ne+np)
- pabort("Subfile sizes don't add up to the stated total!");
-
- }
-
- /*:23*/
- #line 1629 "g:\virtfont\tftopl.web"
- ;
- /*25:*/
- #line 543 "g:\virtfont\tftopl.web"
-
- {char_base= 6+lh-bc;
- width_base= char_base+ec+1;
- height_base= width_base+nw;
- depth_base= height_base+nh;
- italic_base= depth_base+nd;
- lig_kern_base= italic_base+ni;
- kern_base= lig_kern_base+nl;
- exten_base= kern_base+nk;
- param_base= exten_base+ne-1;
- }
-
- /*:25*/
- #line 1630 "g:\virtfont\tftopl.web"
- ;
- return(true);
- final_end:return(false);
- }
-
- /*:98*//*99:*/
- #line 1637 "g:\virtfont\tftopl.web"
- void do_simple_things(void)
- {
- UWORD i;
-
- /*50:*/
- #line 902 "g:\virtfont\tftopl.web"
-
- {font_type= vanilla;
- if(lh>=12)
- {/*55:*/
- #line 971 "g:\virtfont\tftopl.web"
-
- {check_BCPL(scheme,40);
- if((tfm(scheme)>=11)&&(tfm(scheme+1)=='T')&&
- (tfm(scheme+2)=='E')&&(tfm(scheme+3)=='X')&&
- (tfm(scheme+4)==' ')&&(tfm(scheme+5)=='M')&&
- (tfm(scheme+6)=='A')&&(tfm(scheme+7)=='T')&&
- (tfm(scheme+8)=='H')&&(tfm(scheme+9)==' '))
- {if((tfm(scheme+10)=='S')&&(tfm(scheme+11)=='Y'))font_type= mathsy;
- else if((tfm(scheme+10)=='E')&&(tfm(scheme+11)=='X'))font_type= mathex;
- }
- }
-
- /*:55*/
- #line 905 "g:\virtfont\tftopl.web"
- ;
- if(lh>=17)
- {/*57:*/
- #line 988 "g:\virtfont\tftopl.web"
-
- left();out("FAMILY");
- check_BCPL(family,20);
- out_BCPL(family);
- right()
-
- /*:57*/
- #line 907 "g:\virtfont\tftopl.web"
- ;
- if(lh>=18)/*58:*/
- #line 994 "g:\virtfont\tftopl.web"
-
- {left();out("FACE");out_face(random_word+3);right();
- for(i= 18;i<lh;i++)
- {left();out("HEADER D ");outl(i);
- out_octal(check_sum+4*i,4);right();
- }
- }
-
- /*:58*/
- #line 908 "g:\virtfont\tftopl.web"
- ;
- }
- /*56:*/
- #line 983 "g:\virtfont\tftopl.web"
-
- left();out("CODINGSCHEME");
- out_BCPL(scheme);
- right()
-
- /*:56*/
- #line 910 "g:\virtfont\tftopl.web"
- ;
- }
- /*53:*/
- #line 929 "g:\virtfont\tftopl.web"
-
- left();out("DESIGNSIZE");
- if(tfm(design_size)>127)bad_design("negative")
- else if((tfm(design_size)==0)&&(tfm(design_size+1)<16))
- bad_design("too small")
- else out_fix(design_size);
- right();
- out("(COMMENT DESIGNSIZE IS IN POINTS)");out_ln();
- out("(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)");out_ln()
-
-
- /*:53*/
- #line 912 "g:\virtfont\tftopl.web"
- ;
- /*51:*/
- #line 917 "g:\virtfont\tftopl.web"
-
- left();out("CHECKSUM");out_octal(check_sum,4);
- right()
-
- /*:51*/
- #line 913 "g:\virtfont\tftopl.web"
- ;
- /*59:*/
- #line 1008 "g:\virtfont\tftopl.web"
-
- if((lh>17)&&(tfm(random_word)>127))
- {left();out("SEVENBITSAFEFLAG TRUE");right();
- }
-
- /*:59*/
- #line 914 "g:\virtfont\tftopl.web"
- ;
- }
-
- /*:50*/
- #line 1641 "g:\virtfont\tftopl.web"
- ;
- /*60:*/
- #line 1015 "g:\virtfont\tftopl.web"
-
- if(np>0)
- {left();out("FONTDIMEN");out_ln();
- for(i= 1;i<=np;i++)/*62:*/
- #line 1040 "g:\virtfont\tftopl.web"
-
- {left();
- if(i==1)out("SLANT");
- else{check_fix(param(i),"Parameter");
-
- /*63:*/
- #line 1050 "g:\virtfont\tftopl.web"
-
- if(i<=7)switch(i){
- case 2:out("SPACE");break;
- case 3:out("STRETCH");break;
- case 4:out("SHRINK");break;
- case 5:out("XHEIGHT");break;
- case 6:out("QUAD");break;
- case 7:out("EXTRASPACE");break;
- }
- else if((i<=22)&&(font_type==mathsy))switch(i){
- case 8:out("NUM1");break;
- case 9:out("NUM2");break;
- case 10:out("NUM3");break;
- case 11:out("DENOM1");break;
- case 12:out("DENOM2");break;
- case 13:out("SUP1");break;
- case 14:out("SUP2");break;
- case 15:out("SUP3");break;
- case 16:out("SUB1");break;
- case 17:out("SUB2");break;
- case 18:out("SUPDROP");break;
- case 19:out("SUBDROP");break;
- case 20:out("DELIM1");break;
- case 21:out("DELIM2");break;
- case 22:out("AXISHEIGHT");break;
- }
- else if((i<=13)&&(font_type==mathex))
- if(i==8)out("DEFAULTRULETHICKNESS");
- else{out("BIGOPSPACING");outl(i-8);}
- else{out("PARAMETER D ");outl(i);}
-
- /*:63*/
- #line 1045 "g:\virtfont\tftopl.web"
- ;
- }
- out_fix((index)(param(i)));right();
- }
-
- /*:62*/
- #line 1018 "g:\virtfont\tftopl.web"
- ;
- right();
- }
- /*61:*/
- #line 1023 "g:\virtfont\tftopl.web"
-
- if((font_type==mathsy)&&(np!=22))
- fprintf(output,"Unusual number of fontdimen parameters for a math symbols font (%ld not 22).",(long)np);
-
- else if((font_type==mathex)&&(np!=13))
- fprintf(output,"Unusual number of fontdimen parameters for an extension font (%ld not 13).",(long)np);
-
- /*:61*/
- #line 1021 "g:\virtfont\tftopl.web"
- ;
-
- /*:60*/
- #line 1642 "g:\virtfont\tftopl.web"
- ;
- /*64:*/
- #line 1086 "g:\virtfont\tftopl.web"
-
- if(nonzero_fix(4*width_base))bad("width[0] should be zero.");
-
- if(nonzero_fix(4*height_base))bad("height[0] should be zero.");
- if(nonzero_fix(4*depth_base))bad("depth[0] should be zero.");
- if(nonzero_fix(4*italic_base))bad("italic[0] should be zero.");
- for(i= 0;i<nw;i++)check_fix(4*(width_base+i),"Width");
-
- for(i= 0;i<nh;i++)check_fix(4*(height_base+i),"Height");
-
- for(i= 0;i<nd;i++)check_fix(4*(depth_base+i),"Depth");
-
- for(i= 0;i<ni;i++)check_fix(4*(italic_base+i),"Italic correction");
-
- if(nk>0)for(i= 0;i<nk;i++)check_fix(kern(i),"Kern");
-
-
- /*:64*/
- #line 1643 "g:\virtfont\tftopl.web"
-
- }
-
- /*:99*//*100:*/
- #line 1648 "g:\virtfont\tftopl.web"
- void do_characters(void)
- {
- byte c;
- index k;
- lig_size_type ai;
-
- /*80:*/
- #line 1312 "g:\virtfont\tftopl.web"
-
- sort_ptr= 0;
- for(c= bc;c<=ec;c++)if(width_index(c)>0)
- {if(chars_on_line==8)
- {fprintf(output,"%s\n"," ");chars_on_line= 1;
- }
- else{if(chars_on_line>0)putc(' ',output);
- incr(chars_on_line);
- }
- print_octal(c);
- left();out("CHARACTER");out_char(c);out_ln();
- /*81:*/
- #line 1337 "g:\virtfont\tftopl.web"
-
- {left();out("CHARWD");
- if(width_index(c)>=nw)range_error("Width")
- else out_fix((index)(width(c)));
- right();
- }
-
- /*:81*/
- #line 1323 "g:\virtfont\tftopl.web"
- ;
- if(height_index(c)>0)/*82:*/
- #line 1344 "g:\virtfont\tftopl.web"
-
- if(height_index(c)>=nh)range_error("Height")
-
- else{left();out("CHARHT");out_fix((index)(height(c)));right();
- }
-
- /*:82*/
- #line 1324 "g:\virtfont\tftopl.web"
- ;
- if(depth_index(c)>0)/*83:*/
- #line 1350 "g:\virtfont\tftopl.web"
-
- if(depth_index(c)>=nd)range_error("Depth")
-
- else{left();out("CHARDP");out_fix((index)(depth(c)));right();
- }
-
- /*:83*/
- #line 1325 "g:\virtfont\tftopl.web"
- ;
- if(italic_index(c)>0)/*84:*/
- #line 1356 "g:\virtfont\tftopl.web"
-
- if(italic_index(c)>=ni)range_error("Italic correction")
-
- else{left();out("CHARIC");out_fix((index)(italic(c)));right();
- }
-
- /*:84*/
- #line 1326 "g:\virtfont\tftopl.web"
- ;
- switch(tag(c)){
- case no_tag:do_nothing;break;
- case lig_tag:/*85:*/
- #line 1362 "g:\virtfont\tftopl.web"
-
- {left();out("COMMENT");out_ln();
- i= remainder(c);
- r= (UWORD)(lig_step(i));
- if(tfm(r)>stop_flag)i= 256*tfm(r+2)+tfm(r+3);
- do{/*76:*/
- #line 1247 "g:\virtfont\tftopl.web"
-
- {k= (index)(lig_step(i));
- if(tfm(k)>stop_flag)
- {if(256*tfm(k+2)+tfm(k+3)>=nl)
- bad("Ligature unconditional stop command address is too big.");
-
- }
- else if(tfm(k+2)>=kern_flag)/*78:*/
- #line 1272 "g:\virtfont\tftopl.web"
-
- {if(nonexistent(tfm(k+1)))if(tfm(k+1)!=boundary_char)
- correct_bad_char("Kern step for",k+1);
-
- left();out("KRN");out_char(tfm(k+1));
- r= 256*(tfm(k+2)-kern_flag)+tfm(k+3);
- if(r>=nk)
- {bad("Kern index too large.");
-
- out(" R 0.0");
- }
- else out_fix((index)(kern(r)));
- right();
- }
-
- /*:78*/
- #line 1254 "g:\virtfont\tftopl.web"
-
- else/*79:*/
- #line 1287 "g:\virtfont\tftopl.web"
-
- {if(nonexistent(tfm(k+1)))if(tfm(k+1)!=boundary_char)
- correct_bad_char("Ligature step for",k+1);
-
- if(nonexistent(tfm(k+3)))
- correct_bad_char("Ligature step produces the",k+3);
-
- left();r= tfm(k+2);
- if((r==4)||((r>7)&&(r!=11)))
- {fprintf(output,"%s\n","Ligature step with nonstandard code changed to LIG");
- r= 0;tfm(k+2)= 0;
- }
- if(r%4>1)outc('/');
- out("LIG");
- if(odd(r))outc('/');
- while(r>3)
- {outc('>');r= r-4;
- }
- out_char(tfm(k+1));out_char(tfm(k+3));right();
- }
-
- /*:79*/
- #line 1255 "g:\virtfont\tftopl.web"
- ;
- if(tfm(k)>0)
- if(level==1)/*77:*/
- #line 1263 "g:\virtfont\tftopl.web"
-
- {if(tfm(k)>=stop_flag)out("(STOP)");
- else{count= 0;
- for(ai= i+1;ai<=i+tfm(k);ai++)if(activity[ai]==accessible)incr(count);
- out("(SKIP D ");outl(count);outc(')');
- }
- out_ln();
- }
-
- /*:77*/
- #line 1257 "g:\virtfont\tftopl.web"
- ;
- }
-
- /*:76*/
- #line 1367 "g:\virtfont\tftopl.web"
- ;
- if(tfm(k)>=stop_flag)i= nl;
- else i= i+1+tfm(k);
- }while(i<nl);
- right();
- }
-
- /*:85*/
- #line 1330 "g:\virtfont\tftopl.web"
- ;break;
- case list_tag:/*86:*/
- #line 1379 "g:\virtfont\tftopl.web"
-
- {r= remainder(c);
- if(nonexistent(r))
- {bad_char("Character list link to",r);reset_tag(c);
-
- }
- else{while((r<c)&&(tag(r)==list_tag))r= remainder(r);
- if(r==c)
- {bad("Cycle in a character list!");
-
- fprintf(output,"Character ");print_octal(c);
- fprintf(output,"%s\n"," now ends the list.");
- reset_tag(c);
- }
- else{left();out("NEXTLARGER");out_char(remainder(c));
- right();
- }
- }
- }
-
- /*:86*/
- #line 1331 "g:\virtfont\tftopl.web"
- ;break;
- case ext_tag:/*87:*/
- #line 1399 "g:\virtfont\tftopl.web"
-
- if(remainder(c)>=ne)
- {range_error("Extensible");reset_tag(c);
-
- }
- else{left();out("VARCHAR");out_ln();
- /*88:*/
- #line 1409 "g:\virtfont\tftopl.web"
-
- for(k= 0;k<=3;k++)if((k==3)||(tfm(exten(c)+k)>0))
- {left();
- switch(k){
- case 0:out("TOP");break;
- case 1:out("MID");break;
- case 2:out("BOT");break;
- case 3:out("REP");break;
- }
- if(nonexistent(tfm(exten(c)+k)))out_char(c);
- else out_char(tfm(exten(c)+k));
- right();
- }
-
- /*:88*/
- #line 1405 "g:\virtfont\tftopl.web"
- ;
- right();
- }
-
- /*:87*/
- #line 1332 "g:\virtfont\tftopl.web"
- ;break;
- }
- right();
- }
-
- /*:80*/
- #line 1654 "g:\virtfont\tftopl.web"
- ;
- }
-
- /*:100*//*101:*/
- #line 1658 "g:\virtfont\tftopl.web"
-
- /*103:*/
- #line 1689 "g:\virtfont\tftopl.web"
-
- void append_extension(char*name,char*extension)
- {
- char*p;
-
- p= name+strlen(name)-1;
- while(p>name){
- if((*p=='.')||(*p=='\\')||(*p==':'))
- break;
- p--;
- }
- if((p==name)||(*p!='.')){
- strcat(name,".");
- strcat(name,extension);
- }
- else{
- p++;
- if(strcmp(p,extension)!=0)
- strcpy(p,extension);
- }
- }
-
- /*:103*/
- #line 1659 "g:\virtfont\tftopl.web"
-
- int main(int argc,char**argv)
- {
- /*104:*/
- #line 1712 "g:\virtfont\tftopl.web"
-
- argv++;
- argc--;
- if(argc==0){
- fprintf(stderr,"! No TFM file speciefied\n");
- exit(1);
- }
- strcpy(tfm_name,*argv);
- append_extension(tfm_name,"tfm");
- argv++;
- argc--;
-
- if(argc!=0){
- strcpy(pl_name,*argv);
- argv++;
- argc--;
- }
- else
- strcpy(pl_name,tfm_name);
- append_extension(pl_name,"pl");
-
- /*:104*/
- #line 1662 "g:\virtfont\tftopl.web"
-
- initialize();
- if(!organize())return(1);
- do_simple_things();
- /*68:*/
- #line 1137 "g:\virtfont\tftopl.web"
-
- if(nl>0)
- {for(ai= 0;ai<nl;ai++)activity[ai]= unreachable;
- /*71:*/
- #line 1185 "g:\virtfont\tftopl.web"
-
- if(tfm(lig_step(0))==255)
- {left();out("BOUNDARYCHAR");
- boundary_char= tfm(lig_step(0)+1);out_char(boundary_char);right();
- activity[0]= pass_through;
- }
- if(tfm(lig_step(nl-1))==255)
- {r= 256*tfm(lig_step(nl-1)+2)+tfm(lig_step(nl-1)+3);
- if(r>=nl)
- {perfect= false;fprintf(output,"%s\n"," ");
- fprintf(output,"Ligature/kern starting index for boundarychar is too large;");
- fprintf(output,"%s\n","so I removed it.");
-
- }
- else{label_ptr= 1;label_table[1].cc= 256;label_table[1].rr= r;
- bchar_label= r;activity[r]= accessible;
- }
- activity[nl-1]= pass_through;
- }
-
- /*:71*/
- #line 1140 "g:\virtfont\tftopl.web"
- ;
- }
- /*69:*/
- #line 1154 "g:\virtfont\tftopl.web"
-
- for(c= bc;c<=ec;c++)if(tag(c)==lig_tag)
- {r= remainder(c);
- if(r<nl)
- {if(tfm(lig_step(r))>stop_flag)
- {r= 256*tfm(lig_step(r)+2)+tfm(lig_step(r)+3);
- if(r<nl)if(activity[remainder(c)]==unreachable)
- activity[remainder(c)]= pass_through;
- }
- }
- if(r>=nl)
- {perfect= false;fprintf(output,"%s\n"," ");
- fprintf(output,"Ligature/kern starting index for character ");print_octal(c);
- fprintf(output,"%s\n"," is too large;");fprintf(output,"%s\n","so I removed it.");reset_tag(c);
-
- }
- else/*70:*/
- #line 1174 "g:\virtfont\tftopl.web"
-
- {sort_ptr= label_ptr;
- while(label_table[sort_ptr].rr>r)
- {label_table[sort_ptr+1]= label_table[sort_ptr];
- decr(sort_ptr);
- }
- label_table[sort_ptr+1].cc= c;
- label_table[sort_ptr+1].rr= r;
- incr(label_ptr);activity[r]= accessible;
- }
-
- /*:70*/
- #line 1170 "g:\virtfont\tftopl.web"
- ;
- }
- label_table[label_ptr+1].rr= lig_size;
-
- /*:69*/
- #line 1142 "g:\virtfont\tftopl.web"
- ;
- if(nl>0)
- {left();out("LIGTABLE");out_ln();
- /*72:*/
- #line 1205 "g:\virtfont\tftopl.web"
-
- for(ai= 0;ai<nl;ai++)if(activity[ai]==accessible)
- {r= tfm(lig_step(ai));
- if(r<stop_flag)
- {r= r+ai+1;
- if(r>=nl)
- {badp("Ligature/kern step %ld skips too far;",(long)ai);
-
- fprintf(output,"%s\n","I made it stop.");tfm(lig_step(ai))= stop_flag;
- }
- else activity[r]= accessible;
- }
- }
-
- /*:72*/
- #line 1145 "g:\virtfont\tftopl.web"
- ;
- /*73:*/
- #line 1222 "g:\virtfont\tftopl.web"
-
- sort_ptr= 1;
- for(acti= 0;acti<nl;acti++)if(activity[acti]!=pass_through)
- {i= acti;/*75:*/
- #line 1239 "g:\virtfont\tftopl.web"
-
- if(activity[i]==unreachable)
- {if(level==1)
- {left();out("COMMENT THIS PART OF THE PROGRAM IS NEVER USED!");out_ln();
- }
- }
- else if(level==2)right()
-
- /*:75*/
- #line 1225 "g:\virtfont\tftopl.web"
- ;
- /*74:*/
- #line 1231 "g:\virtfont\tftopl.web"
-
- while(i==label_table[sort_ptr].rr)
- {left();out("LABEL");
- if(label_table[sort_ptr].cc==256)out(" BOUNDARYCHAR");
- else out_char(label_table[sort_ptr].cc);
- right();incr(sort_ptr);
- }
-
- /*:74*/
- #line 1226 "g:\virtfont\tftopl.web"
- ;
- /*76:*/
- #line 1247 "g:\virtfont\tftopl.web"
-
- {k= (index)(lig_step(i));
- if(tfm(k)>stop_flag)
- {if(256*tfm(k+2)+tfm(k+3)>=nl)
- bad("Ligature unconditional stop command address is too big.");
-
- }
- else if(tfm(k+2)>=kern_flag)/*78:*/
- #line 1272 "g:\virtfont\tftopl.web"
-
- {if(nonexistent(tfm(k+1)))if(tfm(k+1)!=boundary_char)
- correct_bad_char("Kern step for",k+1);
-
- left();out("KRN");out_char(tfm(k+1));
- r= 256*(tfm(k+2)-kern_flag)+tfm(k+3);
- if(r>=nk)
- {bad("Kern index too large.");
-
- out(" R 0.0");
- }
- else out_fix((index)(kern(r)));
- right();
- }
-
- /*:78*/
- #line 1254 "g:\virtfont\tftopl.web"
-
- else/*79:*/
- #line 1287 "g:\virtfont\tftopl.web"
-
- {if(nonexistent(tfm(k+1)))if(tfm(k+1)!=boundary_char)
- correct_bad_char("Ligature step for",k+1);
-
- if(nonexistent(tfm(k+3)))
- correct_bad_char("Ligature step produces the",k+3);
-
- left();r= tfm(k+2);
- if((r==4)||((r>7)&&(r!=11)))
- {fprintf(output,"%s\n","Ligature step with nonstandard code changed to LIG");
- r= 0;tfm(k+2)= 0;
- }
- if(r%4>1)outc('/');
- out("LIG");
- if(odd(r))outc('/');
- while(r>3)
- {outc('>');r= r-4;
- }
- out_char(tfm(k+1));out_char(tfm(k+3));right();
- }
-
- /*:79*/
- #line 1255 "g:\virtfont\tftopl.web"
- ;
- if(tfm(k)>0)
- if(level==1)/*77:*/
- #line 1263 "g:\virtfont\tftopl.web"
-
- {if(tfm(k)>=stop_flag)out("(STOP)");
- else{count= 0;
- for(ai= i+1;ai<=i+tfm(k);ai++)if(activity[ai]==accessible)incr(count);
- out("(SKIP D ");outl(count);outc(')');
- }
- out_ln();
- }
-
- /*:77*/
- #line 1257 "g:\virtfont\tftopl.web"
- ;
- }
-
- /*:76*/
- #line 1227 "g:\virtfont\tftopl.web"
- ;
- }
- if(level==2)right()
-
- /*:73*/
- #line 1146 "g:\virtfont\tftopl.web"
- ;
- right();
- /*92:*/
- #line 1497 "g:\virtfont\tftopl.web"
-
- hash_ptr= 0;y_lig_cycle= 256;
- for(hh= 0;hh<=hash_size;hh++)hash[hh]= 0;
- for(c= bc;c<=ec;c++)if(tag(c)==lig_tag)
- {i= remainder(c);
- if(tfm(lig_step(i))>stop_flag)
- i= 256*tfm(lig_step(i)+2)+tfm(lig_step(i)+3);
- /*93:*/
- #line 1528 "g:\virtfont\tftopl.web"
-
- do{hash_input();k= tfm(lig_step(i));
- if(k>=stop_flag)i= nl;
- else i= i+1+k;
- }
- while(i<nl);
-
- /*:93*/
- #line 1504 "g:\virtfont\tftopl.web"
- ;
- }
- if(bchar_label<nl)
- {c= 256;i= bchar_label;
- /*93:*/
- #line 1528 "g:\virtfont\tftopl.web"
-
- do{hash_input();k= tfm(lig_step(i));
- if(k>=stop_flag)i= nl;
- else i= i+1+k;
- }
- while(i<nl);
-
- /*:93*/
- #line 1508 "g:\virtfont\tftopl.web"
- ;
- }
- if(hash_ptr==hash_size)
- {fprintf(output,"%s\n","Sorry, I haven't room for so many ligature/kern pairs!");
-
- goto final_end;
- }
- for(hh= 1;hh<=hash_ptr;hh++)
- {r= hash_list[hh];
- if(class[r]>simple)
- r= f(r,(index)((hash[r]-1)/256),(index)((hash[r]-1)%256));
- }
- if(y_lig_cycle<256)
- {fprintf(output,"Infinite ligature loop starting with ");
-
- if(x_lig_cycle==256)fprintf(output,"boundary");else print_octal(x_lig_cycle);
- fprintf(output," and ");print_octal(y_lig_cycle);fprintf(output,"%s\n","!");
- out("(INFINITE LIGATURE LOOP MUST BE BROKEN!)");goto final_end;
- }
-
- /*:92*/
- #line 1148 "g:\virtfont\tftopl.web"
- ;
- }
-
- /*:68*/
- #line 1666 "g:\virtfont\tftopl.web"
- ;
- /*89:*/
- #line 1427 "g:\virtfont\tftopl.web"
-
- if(ne>0)for(c= 0;c<ne;c++)for(d= 0;d<=3;d++)
- {k= (index)(4*(exten_base+c)+d);
- if((tfm(k)>0)||(d==3))
- {if(nonexistent(tfm(k)))
- {bad_char("Extensible recipe involves the",tfm(k));
-
- if(d<3)tfm(k)= 0;
- }
- }
- }
-
- /*:89*/
- #line 1667 "g:\virtfont\tftopl.web"
- ;
- do_characters();fprintf(output,"%s\n",".");
- if(level!=0)fprintf(output,"%s\n","This program isn't working!");
-
- if(!perfect)
- out("(COMMENT THE TFM FILE WAS BAD, SO THE DATA HAS BEEN CHANGED!)");
-
- return(0);
- final_end:return(1);
- }
-
- /*:101*/
-